<template>
  <div class="login-wrap-1">
    <div class="ms-title">
      <img src="../../assets/img/login_topbg.png" alt="">
    </div>
    <a href="#"><p class="text">忘记密码</p></a>
    <div class="ms-login">
      <el-form :model="ruleForm2" status-icon :rules="rules2" ref="ruleForm2" label-width="100px" class="demo-ruleForm">
        <el-form-item label="输入邮箱: " prop="phone">
          <el-input  placeholder="请输入邮箱" v-model.number="ruleForm2.phone"></el-input>
        </el-form-item>
        <el-form-item label="设置密码: " prop="pass">
          <el-input type="password" v-model="ruleForm2.pass" placeholder="设置密码"></el-input>
        </el-form-item>
        <el-form-item label="确认密码: " prop="checkPass">
          <el-input type="password" v-model="ruleForm2.checkPass" placeholder="确认密码"></el-input>
        </el-form-item>
        <el-form-item label="验证码: " prop="confirm"  >
          <el-input v-model="ruleForm2.confirm"  placeholder="输入验证码" class="confirm"></el-input >
        </el-form-item>
        <button class="btn" type="success">发送验证码</button>
        <el-form-item>
          <el-button class="submit" type="primary" @click="submitForm('ruleForm2')">提交</el-button>
          <!--<el-button @click="resetForm('ruleForm2')">重置</el-button>-->
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
  import md5 from 'md5'
  export default {
    data() {
      var checkAge = (rule, value, callback) => {
        if (!value) {
          return callback(new Error('邮箱不能为空'));
        }
        // setTimeout(() => {
        //   if (!Number.isInteger(value)) {
        //     callback(new Error('请输入数字值'));
        //   } else {
        //     if (value< 18) {
        //       callback(new Error('必须年满18岁'));
        //     } else {
        //       callback();
        //     }
        //   }
        // }, 1000);
      };
      var validatePass = (rule, value, callback) => {
        if (value === '') {
          callback(new Error('请输入密码'));
        } else {
          if (this.ruleForm2.checkPass !== '') {
            this.$refs.ruleForm2.validateField('checkPass');
          }
          callback();
        };
      };
      var validatePass2 = (rule, value, callback) => {
        if (value === '') {
          callback(new Error('请再次输入密码'));
        } else if (value !== this.ruleForm2.pass) {
          callback(new Error('两次输入密码不一致!'));
        } else {
          callback();
        }
      };
      var validateConfrim = (rule, value, callback) => {
        if (value === '') {
          callback(new Error('请输入验证码'));
        }
      };
      return {
        ruleForm2: {
          pass: '',
          checkPass: '',
          phone: '',
          confirm:''
        },
        rules2: {
          pass: [
            { validator: validatePass, trigger: 'blur' }
          ],
          checkPass: [
            { validator: validatePass2, trigger: 'blur' }
          ],
          phone: [
            { validator: checkAge, trigger: 'blur' }
          ],
          confirm:[
            { validator: validateConfrim , trigger: 'blur' }
          ]
        }
      };
    },
    methods: {
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            alert('submit!');
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      }
    }
  }
</script>

<style lang="less">
  .login-wrap-1 {
    position: relative;
    width: 100%;
    height: 100%;
    box-sizing: content-box;
    background: #040919 url(../../assets/img/login_bg.png) no-repeat;
    background-size: 100% 100%;
    overflow: hidden;
  }
  .login-wrap-1:after {
    position: absolute;
    top: 0;
    left: 0;
    content: "";
    background-color: #000000;
    opacity: 0.5;
    z-index: 1;
    width: 100%;
    height: 100%;
  }
  .ms-title {
    position: absolute;
    top: 20%;
    width: 100%;
    margin-top: -230px;
    text-align: center;
    font-size: 30px;
    color: #fff;
    z-index: 100;

  }
  .ms-title img {
    width: 400px;
    height: 400px;
  }
  .text {
    position: absolute;
    top: 29%;
    width: 400px;
    text-align: center;
    margin: 0px auto;
    font-size: 22px;
    color: #fff;
    left: 50%;
    margin-left: -200px;
    z-index: 100;
  }
  .yanzheng{
    width: 120px;
    background-color: #666666;
    margin-left:-24px;
  }
  .confirm{
    width:110px;margin-left: -92px;
  }
  .btn{
    width: 100px;
    height: 40px;
    line-height: 42px;
    border-radius:8px;
    outline:0;
    position: absolute;
    top: 226px;
    left:290px;
    background-color:#959a93;
    color: #ffffff;
  }
  .btn:hover{
    background-color: #61c8ff;
  }
  .submit{
    width: 250px;
  }
  .wjpass {
    color: #fff;
    float: left;
    margin-bottom: 6px;
    font-size: 12px;
    margin-top:8px;
    cursor: pointer
  }

  .ms-login {
    position: absolute;
    left: 50%;
    top: 64%;
    width: 300px;
    height: 160px;
    margin: -225px 0 0 -240px;
    padding: 40px;
    border-radius: 5px;
    z-index: 100;
    box-sizing: content-box;
    color: #ffffff;
  }
  .el-form-item__label {
    text-align: right;
    vertical-align: middle;
    float: left;
    font-size: 14px;
    color: #eceef3;
    line-height: 40px;
    padding: 0 12px 0 0;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
  }
  .el-button {
    display: inline-block;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    background: #fff;
    border: 1px solid #dcdfe6;
    color: #606266;
    -webkit-appearance: none;
    text-align: center;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    outline: 0;
    margin: 0;
    -webkit-transition: .1s;
    transition: .1s;
    font-weight: 500;
    padding: 12px 31px;
    font-size: 14px;
    border-radius: 4px;
  }
  .el-input__inner{
    width: 125%;
  }
</style>
